//
//  SelectTableVew.m
//  AriseSamePro
//
//  Created by 包日守 on 15/10/26.
//  Copyright © 2015年 Arise. All rights reserved.
//

#import "SelectTableVew.h"

@interface SelectTableVew ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic) NSArray *arrayTitles;
@property (nonatomic) NSArray *arrayIcons;
@property (nonatomic) NSArray *arrayCates;

@end

@implementation SelectTableVew

- (id) initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    if (self) {
        
        self.dataSource = self;
        self.delegate = self;
        self.arrayTitles = @[@"全部频道",@"文字",@"图片",@"音乐",@"电影",@"语音",@"投票",@"打卡"];
        self.arrayCates = @[@"0",@"1",@"2",@"3",@"4",@"8",@"6",@"7"];
        self.arrayIcons = @[
                            @"search_icon0@2x",
                            @"search_icon1@2x",
                            @"search_icon2@2x",
                            @"search_icon3@2x",
                            @"search_icon4@2x",
                            @"search_icon8@2x",
                            @"search_icon6@2x",
                            @"search_icon7@2x"];
        
        self.title = self.arrayTitles[0];
        
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        self.cate = [NSString stringWithFormat:@"%d",0];
        
    }
    return self;

}


- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.cate = self.arrayCates[indexPath.row];
    
    _title = self.arrayTitles[indexPath.row];
    
    if (indexPath.row == 0) {
        _title = @"全部";
    }
    
    if (self.selectButtonClick) {
        self.selectButtonClick();
    }

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 8;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self dequeueReusableCellWithIdentifier:@"cell"];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
    }
    
    
    cell.imageView.image = [UIImage imageNamed:self.arrayIcons[indexPath.row]];
    cell.clipsToBounds = YES;
    cell.textLabel.text = self.arrayTitles[indexPath.row];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


@end
